package ua.simplecoding.kievhome.dao;

import org.hibernate.Criteria;
import org.springframework.stereotype.Service;
import ua.simplecoding.kievhome.dao.query.AppartmentCriteriaBuilder;
import ua.simplecoding.kievhome.domain.Appartment;
import ua.simplecoding.kievhome.filter.AppartmentFilterVO;

import java.util.List;

@Service("appartmentDao")
public class AppartmentDao extends CustomHibernateDaoSupport implements IAppartmentDao {

    public List<Appartment> findAll() {
        return null;
    }

    public List<Appartment> findByName(String name) {
        return null;
    }

    public Appartment findById(int id) {
        return null;
    }

    public Appartment create(Appartment item) {
        return null;
    }

    public boolean update(Appartment item) {
        return false;
    }

    public boolean remove(Appartment item) {
        return false;
    }

    public Integer getCount(int cityId) {
        return (Integer) getHibernateTemplate().find("select count(app) from Appartment app ").get(0);
    }

    public List<Appartment> search(AppartmentFilterVO appartmentFilterVO) {

        Criteria criteria = new AppartmentCriteriaBuilder(getSession()).buildCriteria(appartmentFilterVO);
        List<Appartment> appartments = criteria.list();

        return appartments;
    }
}
